
TRIGGER PROCEDURE FOR WRITE OF CNSS_MSTR OLD BUFFER OLD_CNSS_MSTR.

{mfdeclre.i }
define new shared work-table wf_old_cnss_mstr like cnss_mstr.

/* fdn 2004/10/28 Modify Record processing */
HK:
do:
    if can-find(first dt_mstr where dt_table = "cnss_mstr" and dt_type = "SYNC") then
        run CreateSyncFlag(input "MOD", input recid(cnss_mstr), input "cnss_mstr").

    if not can-find ( first dt_mstr where dt_table = "cnss_mstr" and dt_type = "MOD" ) then leave HK.
    
    if not can-find ( first wf_old_cnss_mstr ) then do:
        create wf_old_cnss_mstr.
        if recid(wf_old_cnss_mstr)= -1 then .
    end.
    
    buffer-copy old_cnss_mstr to wf_old_cnss_mstr no-error.

    for each dt_mstr no-lock where dt_table = "cnss_mstr" and dt_type = "MOD" :
    
        case dt_field :

            when "cnss_supplier" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_cnss_mstr.cnss_supplier, input cnss_mstr.cnss_supplier,
                    input recid(cnss_mstr), input cnss_mstr.cnss_supplier, input cnss_mstr.cnss_part, input "", input "",
                    input "", input "", input "", input "").

            when "cnss_part" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_cnss_mstr.cnss_part, input cnss_mstr.cnss_part,
                    input recid(cnss_mstr), input cnss_mstr.cnss_supplier, input cnss_mstr.cnss_part, input "", input "",
                    input "", input "", input "", input "").

            when "cnss_consign_flag" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_cnss_mstr.cnss_consign_flag), input string(cnss_mstr.cnss_consign_flag),
                    input recid(cnss_mstr), input cnss_mstr.cnss_supplier, input cnss_mstr.cnss_part, input "", input "",
                    input "", input "", input "", input "").

            when "cnss_max_aging_days" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_cnss_mstr.cnss_max_aging_days), input string(cnss_mstr.cnss_max_aging_days),
                    input recid(cnss_mstr), input cnss_mstr.cnss_supplier, input cnss_mstr.cnss_part, input "", input "",
                    input "", input "", input "", input "").

            when "cnss_mod_userid" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_cnss_mstr.cnss_mod_userid, input cnss_mstr.cnss_mod_userid,
                    input recid(cnss_mstr), input cnss_mstr.cnss_supplier, input cnss_mstr.cnss_part, input "", input "",
                    input "", input "", input "", input "").

            when "cnss_mod_date" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_cnss_mstr.cnss_mod_date), input string(cnss_mstr.cnss_mod_date),
                    input recid(cnss_mstr), input cnss_mstr.cnss_supplier, input cnss_mstr.cnss_part, input "", input "",
                    input "", input "", input "", input "").

            when "cnss_user1" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_cnss_mstr.cnss_user1, input cnss_mstr.cnss_user1,
                    input recid(cnss_mstr), input cnss_mstr.cnss_supplier, input cnss_mstr.cnss_part, input "", input "",
                    input "", input "", input "", input "").

            when "cnss_user2" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_cnss_mstr.cnss_user2, input cnss_mstr.cnss_user2,
                    input recid(cnss_mstr), input cnss_mstr.cnss_supplier, input cnss_mstr.cnss_part, input "", input "",
                    input "", input "", input "", input "").

            when "cnss__qadc01" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_cnss_mstr.cnss__qadc01, input cnss_mstr.cnss__qadc01,
                    input recid(cnss_mstr), input cnss_mstr.cnss_supplier, input cnss_mstr.cnss_part, input "", input "",
                    input "", input "", input "", input "").

            when "cnss__qadc02" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_cnss_mstr.cnss__qadc02, input cnss_mstr.cnss__qadc02,
                    input recid(cnss_mstr), input cnss_mstr.cnss_supplier, input cnss_mstr.cnss_part, input "", input "",
                    input "", input "", input "", input "").

        end.
    end.
end.

{hkdttrans.i}
